[−][src]Crate attohttpc
This project's goal is to provide a lightweight and simple HTTP client for the Rust ecosystem. The intended use is for projects that have HTTP needs where performance is not critical or when HTTP is not the main purpose of the application. Note that the project still tries to perform well and avoid allocation where possible, but stays away from Rust's asynchronous stack to provide a crate that's as small as possible. Features are provided behind feature flags when possible to allow users to get just what they need.
Quick usage
let obj = json!({ "hello": "world", }); let resp = attohttpc::post("https://my-api.org/do/something") .header("X-My-Header", "foo") // set a header for the request .param("qux", "baz") // set a query parameter .json(&obj)? // set the request body .send()?; // send the request // Check if the status is a 2XX code. if resp.is_success() { // Consume the response body as text and print it. println!("{}", resp.text()?); }
Features
charsets
support for decoding more text encodings than just UTF-8compress
support for decompressing response bodies (default)json
support for serialization and deserializationtls
support for tls connections (default)
Check out the repository for more general information and examples.
Re-exports
pub use crate::charsets::Charset; |
Modules
charsets | This module is a clean re-export of the |
header | This module is a re-export of the |
Structs
Error | A type that contains all the errors that can possibly occur while accessing an HTTP server. |
Method | The Request Method (VERB) |
PreparedRequest | Represents a request that's ready to be sent. You can inspect this object for information about the request. |
RequestBuilder |
|
Response |
|
ResponseReader | The |
StatusCode | An HTTP status code ( |
TextReader |
|
Enums
ErrorKind | Common errors that can occur during HTTP requests. |
InvalidResponseKind | Errors than can occur while parsing the response from the server. |
Functions
delete | Create a new |
get | Create a new |
head | Create a new |
options | Create a new |
patch | Create a new |
post | Create a new |
put | Create a new |
trace | Create a new |
Type Definitions
Result | Wrapper for the |